<?php
use common\widgets\Menu;

echo Menu::widget(
    [
        'options' => [
            'class' => 'sidebar-menu'
        ],
        'items' => [
            [
                'label' => Yii::t('app', '首页'),
                'url' => Yii::$app->homeUrl,
                'icon' => 'fa-home',
                'active' => Yii::$app->request->url === Yii::$app->homeUrl,
                'visible' => Yii::$app->user->can('siteIndex'),
            ],

            [
                'label' => Yii::t('app', '一级菜单'),
                'url' => ['#'],
                'icon' => 'ion-gear-b',
                'options' => [
                    'class' => 'treeview',
                ],
                'visible' => Yii::$app->user->can('typeIndex') || Yii::$app->user->can('type-attributeIndex'),
                'items' => [
                    [
                        'label' => Yii::t('app', '二级第一条'),
                        'url' => ['/type/index'],
                        'icon' => 'fa fa-group',
                        'visible' => Yii::$app->user->can('typeIndex'),
                    ],
                    [
                        'label' => Yii::t('app', '二级第二条'),
                        'url' => ['/type-attribute/index'],
                        'icon' => 'ion-person-stalker',
                        'visible' => Yii::$app->user->can('type-attributeIndex'),
                    ]
                ],
            ],
            [
                'label' => Yii::t('app', '系统管理'),
                'url' => ['#'],
                'icon' => 'ion-gear-b',
                'options' => [
                    'class' => 'treeview',
                ],
                'visible' => Yii::$app->user->can('adminIndex') || Yii::$app->user->can('roleIndex') || Yii::$app->user->can('permissionIndex'),
                'items' => [
                    [
                        'label' => Yii::t('app', '管理员管理'),
                        'url' => ['/admin/index'],
                        'icon' => 'fa fa-group',
                        'visible' => Yii::$app->user->can('adminIndex'),
                    ],
                    [
                        'label' => Yii::t('app', '角色管理'),
                        'url' => ['/role/index'],
                        'icon' => 'ion-person-stalker',
                        'visible' => Yii::$app->user->can('roleIndex'),
                    ],
                    [
                        'label' => Yii::t('app', '权限管理'),
                        'url' => ['/permission/index'],
                        'icon' => 'ion-person-stalker',
                        'visible' => Yii::$app->user->can('permissionIndex'),
                    ]
                ],
            ],

            [
                'label' => Yii::t('app', '测试'),
                'url' => ['/test/index'],
                'icon' => 'fa-home',
//                'active' => Yii::$app->request->url === Yii::$app->homeUrl,
                'visible' => true,
            ],

        ]
    ]
);